import 'package:flutter/material.dart';
import 'dart:math' as math;

/// 留出顶部状态栏的位置
class TopAreaWidget extends StatelessWidget {
  final Widget child;
  final Color color;

  TopAreaWidget({this.child, this.color = Colors.black});

  @override
  Widget build(BuildContext context) {
    EdgeInsets padding = MediaQuery.of(context).padding;
    double top = math.max(padding.top, EdgeInsets.zero.top);
    print(top);
    return Flex(
      children: <Widget>[
        Container(
          width: double.infinity,
          height: top,
          color: color,
        ),
        Expanded(
          child: child,
        )
      ],
      direction: Axis.vertical,
    );
  }
}
